package com.ray.controller;

import com.ray.pojo.User;
import com.ray.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class ViewUserController
{

    @Autowired
    private UserServiceImpl userServiceImpl;

    /**
     * @param request  current HTTP request
     * @param response current HTTP response
     * @return
     * @throws Exception
     */

    @RequestMapping("/viewUser")
    public String viewUser(@Nullable @RequestParam("userid") Integer userid, Model model)
    {
        User userById = userServiceImpl.getUserById(userid);
        model.addAttribute("user", userById);
        return "updateUser";
    }
}
